package com.xuecheng.system.convert;

import com.xuecheng.api.system.model.dto.CourseCategoryDTO;
import com.xuecheng.system.entity.CourseCategory;
import com.xuecheng.system.entity.ex.CourseCategoryNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * Created on 2021/03/30/14:35 周二
 *
 * @author Lantin
 */
@Mapper
public interface CourseCategoryConvert {

    CourseCategoryConvert INSTANCE = Mappers.getMapper(CourseCategoryConvert.class);

    @Mappings({
            @Mapping(source = "id", target = "courseCategoryId"),
            @Mapping(source = "childrenTreeNodes", target = "categoryTreeNodes")
    })
    CourseCategoryDTO courseCategoryNodeToDto(CourseCategoryNode node);


    List<CourseCategoryDTO> courseCategoryNodeToDtoList(List<CourseCategoryNode> nodes);

    @Mapping(source = "id", target = "courseCategoryId")
    CourseCategoryDTO CourseCategoryToDTO(CourseCategory category);
}
